package com.cn.wanxi.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.entity.Result;
import com.cn.wanxi.entity.UserEntity;
import com.cn.wanxi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("/back/user")
public class UserController {
    @Autowired
    private IUserService iUserService;

    @RequestMapping("/findAll")
    @ResponseBody
    public  List<UserEntity> findAll(UserEntity userEntity, HttpServletRequest req, HttpServletResponse resp) throws IOException {
        return iUserService.findAll(userEntity);
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("list", list);
//        resp.getWriter().println(jsonObject);
    }

    @RequestMapping("/getCount")
    @ResponseBody
    public Result getCount(UserEntity userEntity, HttpServletResponse resp) throws IOException {
        return iUserService.getCount(userEntity);
//        JSONObject jsonObject = new JSONObject();
////        jsonObject.put("list", list);
//        jsonObject.put("countSize", countSize);
//        resp.getWriter().println(jsonObject);
    }


}
